Repository navigation
fix(num): keep 4 bytes in stringToSha256ToArrayBuff4 when the top byte is zero - #1770
Open
takinanton wants to merge 1 commit into
Open
takinanton wants to merge 1 commit into
takinanton wants to merge 1 commit into
Conversation
…e is zero Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Resolution
num.stringToSha256ToArrayBuff4is documented to return 4 bytes but it goes throughtoHexwhich drops leading zeroes. When the top byte of the masked hash is zero it returns 3 bytes. That happens for about 1 application name in 128, for exampleApp135gives[40, 206, 181].getLedgerPathBuffer111andgetLedgerPathBuffer221concatenate that value so the derivation path comes out 23 bytes long with every later field shifted by one byte.The result is now padded to 8 hex digits before the conversion, the same way the account id is padded in the path builders.
App135gives[0, 40, 206, 181]. Names that already produced 4 bytes are unchanged,LedgerWincluded.RPC version (if applicable)
Not applicable.
Usage related changes
Development related changes
getLedgerPathBuffer111with such a name. Both fail on develop.Checklist:
I ran
npm run test:unit(98 suites pass),ts:check, eslint and prettier on the touched files. I did not run the devnet suites. I found no issue to link. Not tried on a physical Ledger.🤖 Generated with Claude Code